package cn.xeblog.plugin.game.chess2.enums;

/**
 * 棋子类型枚举
 */
public enum PieceType {
    /**
     * 卒/兵
     */
    RED_SOLDIER("RP", Alliance.RED, "兵"),
    /**
     * 士/仕
     */
    RED_ADVISOR("RA", Alliance.RED, "仕"),
    /**
     * 象/相
     */
    RED_ELEPHANT("RB", Alliance.RED, "相"),
    /**
     * 马/馬
     */
    RED_HORSE("RN", Alliance.RED, "馬"),
    /**
     * 炮/砲
     */
    RED_CANNON("RC", Alliance.RED, "砲"),
    /**
     * 車/俥
     */
    RED_CHARIOT("RR", Alliance.RED, "車"),
    /**
     * 将/帥
     */
    RED_GENERAL("RK", Alliance.RED, "帥"),
    /**
     * 卒/兵
     */
    BLACK_SOLDIER("BP", Alliance.BLACK, "卒"),
    /**
     * 士/仕
     */
    BLACK_ADVISOR("BA", Alliance.BLACK, "士"),
    /**
     * 象/相
     */
    BLACK_ELEPHANT("BB", Alliance.BLACK, "象"),
    /**
     * 马/馬
     */
    BLACK_HORSE("BN", Alliance.BLACK, "馬"),
    /**
     * 炮/砲
     */
    BLACK_CANNON("BC", Alliance.BLACK, "炮"),
    /**
     * 車/俥
     */
    BLACK_CHARIOT("BR", Alliance.BLACK, "車"),
    /**
     * 将/帅
     */
    BLACK_GENERAL("BK", Alliance.BLACK, "将"),

    /**
     * 其他
     */
    OTHER("", null, "");

    /**
     * 类型
     */
    private String type;
    /**
     * 所属阵营
     */
    private Alliance alliance;
    /**
     * 中文
     */
    private String chinese;


    PieceType(String type, Alliance alliance, String chinese) {
        this.type = type;
        this.alliance = alliance;
        this.chinese = chinese;
    }

    public static PieceType match(String type) {
        for (PieceType value : values()) {
            if (value.type.equals(type)) {
                return value;
            }
        }
        return PieceType.OTHER;
    }

    public String getType() {
        return type;
    }

    public Alliance getAlliance() {
        return alliance;
    }

    public String getChinese() {
        return chinese;
    }
}
